package com.example.CustomFont;

import com.example.mattrigle.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

public class Textview_custom extends TextView {
	

		public Textview_custom(Context context, AttributeSet attrs, int defStyle) {
			super(context, attrs, defStyle);
			init(attrs);
		}
		
		public Textview_custom(Context context, AttributeSet attrs) {
			super(context, attrs);
			init(attrs);
			
		}
		
		public Textview_custom(Context context) {
			super(context);
			init(null);
		}
		
		private void init(AttributeSet attrs) {
			if (attrs!=null) {
				 TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Textview_custom);
				 String fontName = a.getString(R.styleable.Textview_custom_fontName);
				 if (fontName!=null) {
					 Typeface myTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/"+fontName);
					 setTypeface(myTypeface);
				 }
				 a.recycle();
			}
		}

	

}
